package com.realife.eson.task.coordinate.controller;

import com.realife.eson.common.asserts.AssertNP;
import com.realife.eson.common.result.R;
import com.realife.eson.task.coordinate.entity.TaskListEntity;
import com.realife.eson.task.coordinate.service.TaskListService;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;


/**
 * @author zhangguangcheng
 * @email wums@realife.com
 * @date 2022-06-26 01:35:08
 */
@RestController
@RequestMapping("/coordinate/tasklist")
public class TaskListController {

    @Autowired
    TaskListService taskListService;


    @GetMapping("/insert")
    public R<String> insert() {

        boolean update = false;
        boolean save = false;
        TaskListEntity taskListEntity = new TaskListEntity();
        taskListEntity.setInitiator("wums").setTaskDesc("haha").setTaskPhase(1).setTaskPhaseStatus(0).setTaskSignal("")
                .setExecutor("wums").setCreatedBy("wums").setUpdatedBy("wums");

        save = taskListService.save(taskListEntity);
        if (save) {
            Integer id = taskListEntity.getId();
            taskListEntity.setInitiator("hahaha");
            update = taskListService.updateById(taskListEntity);
        }
        boolean flag = AssertNP.allTrue(save, update);
        if (flag) {
            return R.ok("op success");
        }
        return R.tips("op has wrong");
    }
}
